python3小白课:数值类型之浮点型

我们继续来讲数值类型。

浮点型(float)是另一种数据类型。

我们日常见到的小数,含有小数点的,你就可以理解为属于浮点型。

加上小数点,就会变成了浮点型。即使你写5000.0,它也是一个浮点型,请注意。

浮点型还能表示科学计数法,比如5e3表示5×103即5000。

我们来看点例子:

# coding:utf-8
a = 3.14159
print(type(a))
b = 5000.0
print(type(b))
c = 5e3
print(c)
print(type(c))

大家自己在python shell里面动手试一下就好啦~

单词释义

单词 释义
float 浮动,表示浮点型
Copyright © 雪山凌狐教程 all right reserved,powered by Gitbook该文件修订时间: 2020-04-08 23:49:12

results matching ""

    No results matching ""